import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: 'login',
    hidden: true,
    meta: {
      name: '主页'
    }
  },
  {
    path: '/login',
    name: 'login',
    hidden: true,
    meta: {
      name: '登录'
    },
    component: () => import('../views/login/index.vue')
  },
  {
    path: '/home',
    name: 'Home',
    redirect: 'index',
    meta: {
      name: '控制台',
      icon: 'home'
    },
    component: Layout,
    children: [
      {
        path: '/index',
        name: 'Index',
        meta: {
          name: '首页'
        },
        component: () => import('../views/home/index.vue')
      }
    ]
  },
  {
    path: '/info',
    name: 'Info',
    meta: {
      name: '信息管理',
      icon: 'info'
    },
    component: Layout,
    children: [
      {
        path: '/infoIndex',
        name: 'InfoIndex',
        meta: {
          name: '信息列表'
        },
        component: () => import('../views/info/index.vue')
      },
      {
        path: '/infoCategory',
        name: 'InfoCategory',
        meta: {
          name: '信息分类'
        },
        component: () => import('../views/info/category.vue')
      },
      {
        path: '/infoDetailed',
        name: 'InfoDetailed',
        hidden: true,
        meta: {
          name: '信息详情'
        },
        component: () => import('../views/info/detailed.vue')
      }
    ]
  },
  {
    path: '/user',
    name: 'User',
    meta: {
      name: '用户管理',
      icon: 'user'
    },
    component: Layout,
    children: [
      {
        path: '/userIndex',
        name: 'UserIndex',
        meta: {
          name: '用户列表'
        },
        component: () => import('../views/user/index.vue')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
